<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../layui-v2.6.8/layui/css/layui.css">
    <title>Document</title>
</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <!-- 头部 -->
        {{include'./Public_documents/header.html'}}

        <!-- 左侧 -->
        {{include'./Public_documents/Left_menu.html'}}

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <span class="layui-breadcrumb" lay-separator=">">
                <a href="/">首页</a>
                <a href="/add">列表添加</a>
            </span>
            <div style="padding: 15px;">

                <form id="test" class="layui-form" enctype="multipart/form-data">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类 </label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="name" autocomplete="off">
                        </div>
                    </div>


                    <div class="layui-form-item ">
                        <label class="layui-form-label ">是否显示首页 </label>
                        <div class="layui-input-block">
                            <input type="radio" name="Show_timeornot" value='0' title='显示' checked='checked'>
                            <input type="radio" name="Show_timeornot" value='1' title='不显示'>

                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label "></label>
                        <div class="layui-input-block">
                            <button type="button" id="add"
                                class="layui-btn layui-btn-radius layui-btn-normal">添加</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>


</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="/layui-v2.6.8/layui/layui.js"></script>
<script>
    //JS 
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element
            , layer = layui.layer
            , util = layui.util
            , $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function (othis) {
                layer.msg('展开左侧菜单的操作', { icon: 0 });
            }
            , menuRight: function () {
                layer.open({
                    type: 1
                    , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    , area: ['260px', '100%']
                    , offset: 'rt' //右上角
                    , anim: 5
                    , shadeClose: true
                });
            }
        });
    });

    $('#add').click(() => {

        $.ajax({
            type: 'post',
            url: 'axAddCate',
            data: new FormData($('#test')[0]),
            contentType: false,
            processData: false,
            // let name = $('input["name=name"]').val()
            // let Show_timeornot = $('input["name=Show_timeornot"]:checked').val()
        }).then(({ code, message }) => {
            if (code === 20000) {
                layer.msg(message)
            }else{
                // code:-1,
                layer.msg(message)
            }
        })
    })
</script>

</html>